// ✨封装) 广告管理模型:

// 11. 使用 mongoose 完成广告管理中数据的添加
import mongoose from 'mongoose'

// mongoose.connect('mongodb://localhost/test')
mongoose.connect('mongodb://localhost/edu')

// 11.1 创建一个模型架构, 设计数据结构和约束
const advertSchema = mongoose.Schema({
  title: { type: String, required: true },
  image: { type: String, required: true },
  link: { type: String, required: true },
  start_time: { type: Date, required: true },
  end_time: { type: Date, required: true },
  create_time: { type: Date, default: Date.now },
  last_modified: { type: Date, default: Date.now },
})

// 11.2 通过 mongoose.model 将结构发布
export default mongoose.model('Advert', advertSchema)
